package org.eclipse.ea.requisit.manager.utils;

import java.util.Comparator;

import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.NormalAnnotation;

public class NormalAnnotationComparator implements Comparator<NormalAnnotation> {
	
	public NormalAnnotationComparator(CompilationUnit parser) {
		super();
		this.parser = parser;
	}

	private CompilationUnit parser;

	@Override
	public int compare(NormalAnnotation annotation1, NormalAnnotation annotation2) {
		
		int line1 = parser.getLineNumber(annotation1.getStartPosition());
		int line2 = parser.getLineNumber(annotation2.getStartPosition());
		
		if(line1 < line2){
			return 1;
		}
		
		if(line1 > line2){
			return -1;
		}
		
		return 0;
	}
	
	

}
